using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Resources;

namespace BLF.WWW_WWW.Wiki
{

	/// <summary>
	/// Implements a Resource Exchanger.
	/// </summary>
	public class ResourceExchanger 
    {

		private ResourceManager manager;

		/// <summary>
		/// Initialises a new instance of the <b>ResourceExchanger</b> class.
		/// </summary>
		public ResourceExchanger() {
			manager = new ResourceManager("Resources.Messages", typeof(Resources.Messages).Assembly);
		}

		/// <summary>
		/// Gets a Resource String.
		/// </summary>
		/// <param name="name">The Name of the Resource.</param>
		/// <returns>The Resource String.</returns>
		public string GetResource(string name) 
        {
            //return manager.GetString(name);
            string sReturn = string.Empty;
            try
            {
               sReturn = manager.GetString(name, new System.Globalization.CultureInfo(Lx.Web.Common.UI.Globals.Language));
            }
            catch { sReturn = manager.GetString(name); }
            return sReturn;
		}

	}

    public static class Exchanger
    {

        private static ResourceExchanger resourceExchanger = new ResourceExchanger();

        /// <summary>
        /// Gets or sets the singleton instance of the Resource Exchanger object.
        /// </summary>
        public static ResourceExchanger ResourceExchanger
        {
            get { return resourceExchanger; }
            set { resourceExchanger = value; }
        }

    }

}
